<%
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" +
            request.getServerPort() + request.getContextPath() + "/";
%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <base href="<%=basePath%>">
    <link rel="stylesheet" type="text/css" href="111.css" />
    <script type="text/javascript" src="jQuery/jquery-3.5.1.js"></script>
    <script type="text/javascript">
        var index = 0;
        function findFocus(){
            var sou = document.getElementById("sousuo");
            sou.style.border = "1px solid rgb(250,125,60)";
            sou.style.backgroundColor = "rgb(255,255,255)";
        }
        function findBlur(){
            var sou = document.getElementById("sousuo");
            sou.style.border = "1px solid rgb(180,180,180)";
            sou.style.backgroundColor = "rgb(242,241,241)"
        }
        function chaOver(){
            var cha = document.getElementById("cha");
            cha.src = "img/two.png";
        }
        function chaOut(){
            var cha = document.getElementById("cha");
            cha.src = "img/one.png";
        }
        function outOver(){
            var tui = document.getElementById("tui");
            tui.src = "img/outTwo.png";
            document.getElementById("out").style.color = "rgb(250,125,60)";
        }
        function outOut(){
            var tui = document.getElementById("tui");
            tui.src = "img/out.png";
            document.getElementById("out").style.color = "black";
        }
        function leftLiOver(i){
            $(".leftLi")[i].style.backgroundColor = "rgba(200,200,200,0.4)";
        }
        function leftLiOut(i){
            $(".leftLi")[i].style.backgroundColor = "";
            $(".leftLi")[index].style.backgroundColor = "rgba(200,200,200,0.4)";
        }
        function setIframeHeight(iframe) {
            if (iframe) {
                var iframeWin = iframe.contentWindow || iframe.contentDocument.parentWindow;
                if (iframeWin.document.body) {
                    iframe.height = iframeWin.document.documentElement.scrollHeight || iframeWin.document.body.scrollHeight;
                }
            }
        };
        window.onload = function () {
            setIframeHeight(document.getElementById('external-frame'));
            $(".leftLi")[0].click();
        };
        function one(i){
            index = i;
            var arr = $(".leftLi");
            arr.each(function(index,element){
                element.style.backgroundColor = "";
            })
            $(".leftLi")[index].style.backgroundColor = "rgba(200,200,200,0.4)";
            setInterval(frame,2);
            function frame(){
                setIframeHeight(document.getElementById('external-frame'));
            }
        }
        function findOne(){
            var find = document.getElementById("find").value;
            if (find === ""){
                alert("请输入要搜索的内容！")
            } else {
                document.getElementById("form1").submit();
            }
        }
        function logout(obj){
            obj.submit();
        }
    </script>
</head>
<%
    String username = (String) request.getAttribute("username");
    Integer userType = (Integer) request.getAttribute("userType");
    if (username == null){
        username = (String) session.getAttribute("username");
        userType = (Integer) session.getAttribute("userType");
    }
    String sou = (String) request.getAttribute("dynamicTwo");
    session.setAttribute("username",username);
    session.setAttribute("userType",userType);
    if (sou != null){
%>
    <script type="text/javascript">
        $(function(){
            $("#find").val("<%=sou%>");
            $("#cha").click();
        })
    </script>
<%
    }

%>
<body>
<div id="top">
    <div id="logo" style="cursor: pointer">
        <img src="img/logo.jpg">
    </div>
    <div id="sousuo">
        <form action="dynamic/selectSome.do" method="post" target="right" id="form1">
            <input type="text" id="find" onfocus="findFocus()" onblur="findBlur()" placeholder="搜索微博/找人" name="dynamic">
            <img src="img/one.png" id="cha" onclick="findOne()" onmouseover="chaOver()" onmouseout="chaOut()" style="margin-left: 5px; margin-top: 5px; float: left; cursor: pointer">
        </form>

    </div>
    <form action="user/logout.do" method="post" target="_parent" id="form2">
        <input type="text" name="userType" value="<%=userType%>" style="display: none"/>
        <div id="out" onmouseover="outOver()" onmouseout="outOut()" onclick="logout(document.getElementById('form2'))">
            <img src="img/out.png" id="tui" height="30px" style="margin-top: 5px;float: left">
            &nbsp;退出
        </div>
    </form>
</div>
<div id="left">
    <ul>
        <li>
            <a href="dynamic/selectAll.do" target="right">
                <div class="leftLi" style="margin-top: 20px;background-color: rgba(200,200,200,0.4)" onmouseover="leftLiOver(0)" onmouseout="leftLiOut(0)" onclick="one(0)">
                    首    页
                </div>
            </a>
        </li>
        <li>
            <a href="collect/selectSelf.do?name=<%=username%>" target="right">
                <div class="leftLi" onmouseover="leftLiOver(1)" onmouseout="leftLiOut(1)" onclick="one(1)">
                    我的收藏
                </div>
            </a>
        </li>
        <li>
            <a href="thumbs/selectSelf.do?name=<%=username%>" target="right">
                <div class="leftLi" onmouseover="leftLiOver(2)" onmouseout="leftLiOut(2)" onclick="one(2)">
                    我 的 赞
                </div>
            </a>
        </li>
        <li>
            <a href="dynamic/selectFollow.do?name=<%=username%>" target="right">
                <div class="leftLi" onmouseover="leftLiOver(3)" onmouseout="leftLiOut(3)" onclick="one(3)">
                    我的关注
                </div>
            </a>
        </li>
        <li>
            <a href="follow/selectSelf.do?name=<%=username%>" target="right">
                <div class="leftLi" onmouseover="leftLiOver(4)" onmouseout="leftLiOut(4)" onclick="one(4)">
                    关注列表
                </div>
            </a>
        </li>
        <li>
            <a href="user/findFans.do?name=<%=username%>" target="right">
                <div class="leftLi" onmouseover="leftLiOver(5)" onmouseout="leftLiOut(5)" onclick="one(5)">
                    我的粉丝
                </div>
            </a>
        </li>
        <li>
            <a href="dynamic/selectSelfDynamic.do?name=<%=username%>" target="right">
                <div class="leftLi" onmouseover="leftLiOver(6)" onmouseout="leftLiOut(6)" onclick="one(6)">
                    我的微博
                </div>
            </a>
        </li>
        <%
            if (userType == 0) {
        %>
        <li>
            <a href="provide/loadAllFood.do" target="right">
                <div class="leftLi" onmouseover="leftLiOver(7)" onmouseout="leftLiOut(7)" onclick="one(7)">
                    点    餐
                </div>
            </a>
        </li>
        <li>
            <a href="order/loadUserOrder.do?name=<%=username%>" target="right">
                <div class="leftLi" onmouseover="leftLiOver(8)" onmouseout="leftLiOut(8)" onclick="one(8)">
                    我的订单
                </div>
            </a>
        </li>
        <%
            } else if (userType == 1) {
        %>
        <li>
            <a href="provide/loadUserFood.do?name=<%=username%>" target="right">
                <div class="leftLi" onmouseover="leftLiOver(7)" onmouseout="leftLiOut(7)" onclick="one(7)">
                    我的餐品
                </div>
            </a>
        </li>
        <li>
            <a href="order/loadProviderOrder.do?name=<%=username%>" target="right">
                <div class="leftLi" onmouseover="leftLiOver(8)" onmouseout="leftLiOut(8)" onclick="one(8)">
                    用户订单
                </div>
            </a>
        </li>
        <%
            } else {
        %>
        <li>
            <a href="order/loadUserTakeOrder.do?name=<%=username%>" target="right">
                <div class="leftLi" onmouseover="leftLiOver(7)" onmouseout="leftLiOut(7)" onclick="one(7)">
                    我的接单
                </div>
            </a>
        </li>
        <li>
            <a href="order/loadNoTakeOrder.do" target="right">
                <div class="leftLi" onmouseover="leftLiOver(8)" onmouseout="leftLiOut(8)" onclick="one(8)">
                    全部订单
                </div>
            </a>
        </li>
        <%
            }
        %>
    </ul>
</div>
<div id="right">
    <iframe name="right" id="external-frame">

    </iframe>
</div>
</body>
</html>
